﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ConsoleApplicationWriteToFile
{
    class Program
    {
       static long CalculateFactorial(int number)
        {

            int counter = 1;
            long factorialValue = 1;

            while (counter++ < number)
            {
                factorialValue = factorialValue * counter;
            }

            return factorialValue;

        }

        static void Main(string[] args)
        {
            char counterChar = 'A';
            string currentPathDirectory = Directory.GetCurrentDirectory();
            string extension = "xxx";
            int throughCounter=1;
            string dateCreate= DateTime.Now.ToString();
       
            while (counterChar <= 'Z')
            {
                Directory.CreateDirectory(String.Format("{0}\\{1}", currentPathDirectory, counterChar));
                int counterInt = 1;
                while (counterInt <= 1000)
                {
                  
                    using (FileStream fstream = new FileStream(@String.Format("{0}\\{1}\\{2}.{3}", currentPathDirectory, counterChar, counterInt, extension), FileMode.OpenOrCreate))
                        {
                          // преобразуем строку в байты
                          byte[] array = System.Text.Encoding.Default.GetBytes(String.Format("{0}   {1}", throughCounter, dateCreate));
                          // запись массива байтов в файл
                          fstream.Write(array, 0, array.Length);
                          //Console.WriteLine("Текст записан в файл");
                        }
                    
                    counterInt++;
                    throughCounter++;
                }
                counterChar++;
            };

        }
    }
}
